package com.example.my_tool_2;

import android.content.Context;
import android.content.SharedPreferences;

import java.net.Socket;
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.BatteryManager;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.widget.EditText;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import java.util.List;

public class Main {
    SharedPreferences config;
    SharedPreferences.Editor editor;

    String tv_connect_text;
    int tv_connect_text_color;
    int tv_connect_text_Shadow_color;

    String tv_ping_text;
    int tv_ping_text_color;
    int tv_ping_text_Shadow_color;


    String et_ip_text;
    String et_port_text;

    int tv_data_match_text_Shadow_color;


    byte[] car_sign = new byte[3];
    byte work_sign;

    Main(SharedPreferences Config,SharedPreferences.Editor Editor)
    {
        config = Config;
        editor = Editor;
        tv_connect_text = "未连接";
        tv_connect_text_color = R.color.black;
        tv_connect_text_Shadow_color = R.color.crimson;


        tv_ping_text = "500ms";
        tv_ping_text_color = R.color.black;
        tv_ping_text_Shadow_color = R.color.crimson;

        String str = config.getString("et_ip_text", "null");
        if (str.equals("null")){
            et_ip_text = "192.168.100.105";
            editor.putString("et_ip_text", et_ip_text);
            editor.apply();
        }
        else{
            et_ip_text = str;
        }
        str = config.getString("et_port_text", "null");
        if (str.equals("null")){
            et_port_text = "45678";
            editor.putString("et_port_text", et_port_text);
            editor.apply();
        }
        else{
            et_port_text = str;
        }

        tv_data_match_text_Shadow_color= R.color.crimson;

        byte Byte = (byte)config.getInt("car_sign0", 0);
        car_sign[0]=Byte;
        Byte = (byte)config.getInt("car_sign1", 0);
        car_sign[1]=Byte;
        Byte = (byte)config.getInt("car_sign2", 0);
        car_sign[2]=Byte;
        Byte = (byte)config.getInt("work_sign", 0);
        work_sign=Byte;

    }//构造函数





}
